A) We were referenceing shortname after we'd freed it.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 22 Nov 2004 06:17:26 +0000 (06:17 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 22 Nov 2004 06:17:26 +0000 (06:17 +0000)
B) If we were using prefer_shortname and had a description we'd free
   shortname twice, resulting in a process that would never exit becuase
   of heap corruption on FC2.  (Other OSes would surely have similarly
   entertaing failure modes.)

gpsbabel/csv_util.c

index 4d426382ca34638d59cda162c167186075ab872e..1c55aacd3002303dbe3de2ff0868a7dcb3c91cb0 100644 (file)
@@ -856,10 +856,8 @@ xcsv_waypt_pr(const waypoint *wpt)
            if (description) {
                    xfree(description);
            }
-           description = shortname;
-    }
-
-    if (description) {
+           description = shortname;
+    } else if (description) {
            char *odesc = description;
            description = str_utf8_to_ascii(odesc);
            xfree(odesc);
@@ -1070,12 +1068,12 @@ xcsv_waypt_pr(const waypoint *wpt)
 
     fprintf (xcsv_file.xcsvfp, "%s", xcsv_file.record_delimiter);
 
-    if (shortname)
-        xfree(shortname);
-
     if (description && description != shortname)
         xfree(description);
 
+    if (shortname)
+        xfree(shortname);
+
     /* increment the index counter */
     waypt_out_count++;
 }